home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / ANTENNA / YAGIU112 / NRUTIL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-07  |  15.8 KB  |  616 lines

  1. #if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
  2.  
  3. #include <stdio.h>
  4. #include <stddef.h>
  5. #ifndef GCC
  6. #include <stdlib.h>   
  7. #endif
  8. #define NR_END 1
  9. #define FREE_ARG char*
  10.  
  11. void nrerror(char error_text[])
  12. /* Numerical Recipes standard error handler */
  13. {
  14.     fprintf(stderr,"Numerical Recipes run-time error...\n");
  15.     fprintf(stderr,"%s\n",error_text);
  16.     fprintf(stderr,"...now exiting to system...\n");
  17.     exit(1);
  18. }
  19.  
  20. float *vector(long nl, long nh)
  21. /* allocate a float vector with subscript range v[nl..nh] */
  22. {
  23.     float *v;
  24.  
  25.     v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
  26.     if (!v) nrerror("allocation failure in vector()");
  27.     return v-nl+NR_END;
  28. }
  29.  
  30. int *ivector(long nl, long nh)
  31. /* allocate an int vector with subscript range v[nl..nh] */
  32. {
  33.     int *v;
  34.  
  35.     v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
  36.     if (!v) nrerror("allocation failure in ivector()");
  37.     return v-nl+NR_END;
  38. }
  39.  
  40. unsigned char *cvector(long nl, long nh)
  41. /* allocate an unsigned char vector with subscript range v[nl..nh] */
  42. {
  43.     unsigned char *v;
  44.  
  45.     v=(unsigned char *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
  46.     if (!v) nrerror("allocation failure in cvector()");
  47.     return v-nl+NR_END;
  48. }
  49.  
  50. unsigned long *lvector(long nl, long nh)
  51. /* allocate an unsigned long vector with subscript range v[nl..nh] */
  52. {
  53.     unsigned long *v;
  54.  
  55.     v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(long)));
  56.     if (!v) nrerror("allocation failure in lvector()");
  57.     return v-nl+NR_END;
  58. }
  59.  
  60. double *dvector(long nl, long nh)
  61. /* allocate a double vector with subscript range v[nl..nh] */
  62. {
  63.     double *v;
  64.     v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
  65.     if (!v) nrerror("allocation failure in dvector()");
  66.     return v-nl+NR_END;
  67. }
  68.  
  69. float **matrix(long nrl, long nrh, long ncl, long nch)
  70. /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
  71. {
  72.     long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
  73.     float **m;
  74.  
  75.     /* allocate pointers to rows */
  76.     m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*)));
  77.     if (!m) nrerror("allocation failure 1 in matrix()");
  78.     m += NR_END;
  79.     m -= nrl;
  80.  
  81.     /* allocate rows and set pointers to them */
  82.     m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
  83.     if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
  84.     m[nrl] += NR_END;
  85.     m[nrl] -= ncl;
  86.  
  87.     for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
  88.  
  89.     /* return pointer to array of pointers to rows */
  90.     return m;
  91. }
  92.  
  93. double **dmatrix(long nrl, long nrh, long ncl, long nch)
  94. /* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
  95. {
  96.     long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
  97.     double **m;
  98.  
  99.     /* allocate pointers to rows */
  100.     m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
  101.     if (!m) nrerror("allocation failure 1 in matrix()");
  102.     m += NR_END;
  103.     m -= nrl;
  104.  
  105.     /* allocate rows and set pointers to them */
  106.     m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
  107.     if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
  108.     m[nrl] += NR_END;
  109.     m[nrl] -= ncl;
  110.  
  111.     for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
  112.  
  113.     /* return pointer to array of pointers to rows */
  114.     return m;
  115. }
  116.  
  117. int **imatrix(long nrl, long nrh, long ncl, long nch)
  118. /* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
  119. {
  120.     long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
  121.     int **m;
  122.  
  123.     /* allocate pointers to rows */
  124.     m=(int **) malloc((size_t)((nrow+NR_END)*sizeof(int*)));
  125.     if (!m) nrerror("allocation failure 1 in matrix()");
  126.     m += NR_END;
  127.     m -= nrl;
  128.  
  129.  
  130.     /* allocate rows and set pointers to them */
  131.     m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int)));
  132.     if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
  133.     m[nrl] += NR_END;
  134.     m[nrl] -= ncl;
  135.  
  136.     for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
  137.  
  138.     /* return pointer to array of pointers to rows */
  139.     return m;
  140. }
  141.  
  142. float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
  143.     long newrl, long newcl)
  144. /* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
  145. {
  146.     long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
  147.     float **m;
  148.  
  149.     /* allocate array of pointers to rows */
  150.     m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
  151.     if (!m) nrerror("allocation failure in submatrix()");
  152.     m += NR_END;
  153.     m -= newrl;
  154.  
  155.     /* set pointers to rows */
  156.     for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
  157.  
  158.     /* return pointer to array of pointers to rows */
  159.     return m;
  160. }
  161.  
  162. float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch)
  163. /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
  164. declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
  165. and ncol=nch-ncl+1. The routine should be called with the address
  166. &a[0][0] as the first argument. */
  167. {
  168.     long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
  169.     float **m;
  170.  
  171.     /* allocate pointers to rows */
  172.     m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
  173.     if (!m) nrerror("allocation failure in convert_matrix()");
  174.     m += NR_END;
  175.     m -= nrl;
  176.  
  177.     /* set pointers to rows */
  178.     m[nrl]=a-ncl;
  179.     for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
  180.     /* return pointer to array of pointers to rows */
  181.     return m;
  182. }
  183.  
  184. float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
  185. /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
  186. {
  187.     long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
  188.     float ***t;
  189.  
  190.     /* allocate pointers to pointers to rows */
  191.     t=(float ***) malloc((size_t)((nrow+NR_END)*sizeof(float**)));
  192.     if (!t) nrerror("allocation failure 1 in f3tensor()");
  193.     t += NR_END;
  194.     t -= nrl;
  195.  
  196.     /* allocate pointers to rows and set pointers to them */
  197.     t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
  198.     if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
  199.     t[nrl] += NR_END;
  200.     t[nrl] -= ncl;
  201.  
  202.     /* allocate rows and set pointers to them */
  203.     t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
  204.     if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
  205.     t[nrl][ncl] += NR_END;
  206.     t[nrl][ncl] -= ndl;
  207.  
  208.     for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
  209.     for(i=nrl+1;i<=nrh;i++) {
  210.         t[i]=t[i-1]+ncol;
  211.         t[i][ncl]=t[i-1][ncl]+ncol*ndep;
  212.         for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
  213.     }
  214.  
  215.     /* return pointer to array of pointers to rows */
  216.     return t;
  217. }
  218.  
  219. void free_vector(float *v, long nl, long nh)
  220. /* free a float vector allocated with vector() */
  221. {
  222.     free((FREE_ARG) (v+nl-NR_END));
  223. }
  224.  
  225. void free_ivector(int *v, long nl, long nh)
  226. /* free an int vector allocated with ivector() */
  227. {
  228.     free((FREE_ARG) (v+nl-NR_END));
  229. }
  230.  
  231. void free_cvector(unsigned char *v, long nl, long nh)
  232. /* free an unsigned char vector allocated with cvector() */
  233. {
  234.     free((FREE_ARG) (v+nl-NR_END));
  235. }
  236.  
  237. void free_lvector(unsigned long *v, long nl, long nh)
  238. /* free an unsigned long vector allocated with lvector() */
  239. {
  240.     free((FREE_ARG) (v+nl-NR_END));
  241. }
  242.  
  243. void free_dvector(double *v, long nl, long nh)
  244. /* free a double vector allocated with dvector() */
  245. {
  246.     free((FREE_ARG) (v+nl-NR_END));
  247. }
  248.  
  249. void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
  250. /* free a float matrix allocated by matrix() */
  251. {
  252.     free((FREE_ARG) (m[nrl]+ncl-NR_END));
  253.     free((FREE_ARG) (m+nrl-NR_END));
  254. }
  255.  
  256. void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
  257. /* free a double matrix allocated by dmatrix() */
  258. {
  259.     free((FREE_ARG) (m[nrl]+ncl-NR_END));
  260.     free((FREE_ARG) (m+nrl-NR_END));
  261. }
  262.  
  263. void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
  264. /* free an int matrix allocated by imatrix() */
  265. {
  266.     free((FREE_ARG) (m[nrl]+ncl-NR_END));
  267.     free((FREE_ARG) (m+nrl-NR_END));
  268. }
  269.  
  270. void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch)
  271. /* free a submatrix allocated by submatrix() */
  272. {
  273.     free((FREE_ARG) (b+nrl-NR_END));
  274. }
  275.  
  276. void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch)
  277. /* free a matrix allocated by convert_matrix() */
  278. {
  279.     free((FREE_ARG) (b+nrl-NR_END));
  280. }
  281.  
  282. void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
  283.     long ndl, long ndh)
  284. /* free a float f3tensor allocated by f3tensor() */
  285. {
  286.     free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
  287.     free((FREE_ARG) (t[nrl]+ncl-NR_END));
  288.     free((FREE_ARG) (t+nrl-NR_END));
  289. }
  290.  
  291. #else /* ANSI */
  292. /* traditional - K&R */
  293.  
  294. #include <stdio.h>
  295. #define NR_END 1
  296. #define FREE_ARG char*
  297.  
  298. void nrerror(error_text)
  299. char error_text[];
  300. /* Numerical Recipes standard error handler */
  301. {
  302.     void exit();
  303.  
  304.     fprintf(stderr,"Numerical Recipes run-time error...\n");
  305.     fprintf(stderr,"%s\n",error_text);
  306.     fprintf(stderr,"...now exiting to system...\n");
  307.     exit(1);
  308. }
  309.  
  310. float *vector(nl,nh)
  311. long nh,nl;
  312. /* allocate a float vector with subscript range v[nl..nh] */
  313. {
  314.     float *v;
  315.  
  316.     v=(float *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(float)));
  317.     if (!v) nrerror("allocation failure in vector()");
  318.     return v-nl+NR_END;
  319. }
  320.  
  321. int *ivector(nl,nh)
  322. long nh,nl;
  323. /* allocate an int vector with subscript range v[nl..nh] */
  324. {
  325.     int *v;
  326.  
  327.     v=(int *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(int)));
  328.     if (!v) nrerror("allocation failure in ivector()");
  329.     return v-nl+NR_END;
  330. }
  331.  
  332. unsigned char *cvector(nl,nh)
  333. long nh,nl;
  334. /* allocate an unsigned char vector with subscript range v[nl..nh] */
  335. {
  336.     unsigned char *v;
  337.  
  338.     v=(unsigned char *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
  339.     if (!v) nrerror("allocation failure in cvector()");
  340.     return v-nl+NR_END;
  341. }
  342.  
  343. unsigned long *lvector(nl,nh)
  344. long nh,nl;
  345. /* allocate an unsigned long vector with subscript range v[nl..nh] */
  346. {
  347.     unsigned long *v;
  348.  
  349.     v=(unsigned long *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(long)));
  350.     if (!v) nrerror("allocation failure in lvector()");
  351.     return v-nl+NR_END;
  352. }
  353.  
  354. double *dvector(nl,nh)
  355. long nh,nl;
  356. /* allocate a double vector with subscript range v[nl..nh] */
  357. {
  358.     double *v;
  359.  
  360.     v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
  361.     if (!v) nrerror("allocation failure in dvector()");
  362.     return v-nl+NR_END;
  363. }
  364.  
  365. float **matrix(nrl,nrh,ncl,nch)
  366. long nch,ncl,nrh,nrl;
  367. /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
  368. {
  369.     long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
  370.     float **m;
  371.  
  372.     /* allocate pointers to rows */
  373.     m=(float **) malloc((unsigned int)((nrow+NR_END)*sizeof(float*)));
  374.     if (!m) nrerror("allocation failure 1 in matrix()");
  375.     m += NR_END;
  376.     m -= nrl;
  377.  
  378.     /* allocate rows and set pointers to them */
  379.     m[nrl]=(float *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float)));
  380.     if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
  381.     m[nrl] += NR_END;
  382.     m[nrl] -= ncl;
  383.  
  384.     for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
  385.  
  386.     /* return pointer to array of pointers to rows */
  387.     return m;
  388. }
  389.  
  390. double **dmatrix(nrl,nrh,ncl,nch)
  391. long nch,ncl,nrh,nrl;
  392. /* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
  393. {
  394.     long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
  395.     double **m;
  396.  
  397.     /* allocate pointers to rows */
  398.     m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
  399.     if (!m) nrerror("allocation failure 1 in matrix()");
  400.     m += NR_END;
  401.     m -= nrl;
  402.  
  403.     /* allocate rows and set pointers to them */
  404.     m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
  405.     if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
  406.     m[nrl] += NR_END;
  407.     m[nrl] -= ncl;
  408.  
  409.     for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
  410.  
  411.     /* return pointer to array of pointers to rows */
  412.     return m;
  413. }
  414.  
  415. int **imatrix(nrl,nrh,ncl,nch)
  416. long nch,ncl,nrh,nrl;
  417. /* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
  418. {
  419.     long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
  420.     int **m;
  421.  
  422.     /* allocate pointers to rows */
  423.     m=(int **) malloc((unsigned int)((nrow+NR_END)*sizeof(int*)));
  424.     if (!m) nrerror("allocation failure 1 in matrix()");
  425.     m += NR_END;
  426.     m -= nrl;
  427.  
  428.  
  429.     /* allocate rows and set pointers to them */
  430.     m[nrl]=(int *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(int)));
  431.     if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
  432.     m[nrl] += NR_END;
  433.     m[nrl] -= ncl;
  434.  
  435.     for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
  436.  
  437.     /* return pointer to array of pointers to rows */
  438.     return m;
  439. }
  440.  
  441. float **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
  442. float **a;
  443. long newcl,newrl,oldch,oldcl,oldrh,oldrl;
  444. /* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
  445. {
  446.     long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
  447.     float **m;
  448.  
  449.     /* allocate array of pointers to rows */
  450.     m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
  451.     if (!m) nrerror("allocation failure in submatrix()");
  452.     m += NR_END;
  453.     m -= newrl;
  454.  
  455.     /* set pointers to rows */
  456.     for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
  457.  
  458.     /* return pointer to array of pointers to rows */
  459.     return m;
  460. }
  461.  
  462. float **convert_matrix(a,nrl,nrh,ncl,nch)
  463. float *a;
  464. long nch,ncl,nrh,nrl;
  465. /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
  466. declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
  467. and ncol=nch-ncl+1. The routine should be called with the address
  468. &a[0][0] as the first argument. */
  469. {
  470.     long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
  471.     float **m;
  472.  
  473.     /* allocate pointers to rows */
  474.     m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
  475.     if (!m)    nrerror("allocation failure in convert_matrix()");
  476.     m += NR_END;
  477.     m -= nrl;
  478.  
  479.     /* set pointers to rows */
  480.     m[nrl]=a-ncl;
  481.     for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
  482.     /* return pointer to array of pointers to rows */
  483.     return m;
  484. }
  485.  
  486. float ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
  487. long nch,ncl,ndh,ndl,nrh,nrl;
  488. /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
  489. {
  490.     long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
  491.     float ***t;
  492.  
  493.     /* allocate pointers to pointers to rows */
  494.     t=(float ***) malloc((unsigned int)((nrow+NR_END)*sizeof(float**)));
  495.     if (!t) nrerror("allocation failure 1 in f3tensor()");
  496.     t += NR_END;
  497.     t -= nrl;
  498.  
  499.     /* allocate pointers to rows and set pointers to them */
  500.     t[nrl]=(float **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float*)));
  501.     if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
  502.     t[nrl] += NR_END;
  503.     t[nrl] -= ncl;
  504.  
  505.     /* allocate rows and set pointers to them */
  506.     t[nrl][ncl]=(float *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(float)));
  507.     if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
  508.     t[nrl][ncl] += NR_END;
  509.     t[nrl][ncl] -= ndl;
  510.  
  511.     for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
  512.     for(i=nrl+1;i<=nrh;i++) {
  513.         t[i]=t[i-1]+ncol;
  514.         t[i][ncl]=t[i-1][ncl]+ncol*ndep;
  515.         for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
  516.     }
  517.  
  518.     /* return pointer to array of pointers to rows */
  519.     return t;
  520. }
  521.  
  522. void free_vector(v,nl,nh)
  523. float *v;
  524. long nh,nl;
  525. /* free a float vector allocated with vector() */
  526. {
  527.     free((FREE_ARG) (v+nl-NR_END));
  528. }
  529.  
  530. void free_ivector(v,nl,nh)
  531. int *v;
  532. long nh,nl;
  533. /* free an int vector allocated with ivector() */
  534. {
  535.     free((FREE_ARG) (v+nl-NR_END));
  536. }
  537.  
  538. void free_cvector(v,nl,nh)
  539. long nh,nl;
  540. unsigned char *v;
  541. /* free an unsigned char vector allocated with cvector() */
  542. {
  543.     free((FREE_ARG) (v+nl-NR_END));
  544. }
  545.  
  546. void free_lvector(v,nl,nh)
  547. long nh,nl;
  548. unsigned long *v;
  549. /* free an unsigned long vector allocated with lvector() */
  550. {
  551.     free((FREE_ARG) (v+nl-NR_END));
  552. }
  553.  
  554. void free_dvector(v,nl,nh)
  555. double *v;
  556. long nh,nl;
  557. /* free a double vector allocated with dvector() */
  558. {
  559.     free((FREE_ARG) (v+nl-NR_END));
  560. }
  561.  
  562. void free_matrix(m,nrl,nrh,ncl,nch)
  563. float **m;
  564. long nch,ncl,nrh,nrl;
  565. /* free a float matrix allocated by matrix() */
  566. {
  567.     free((FREE_ARG) (m[nrl]+ncl-NR_END));
  568.     free((FREE_ARG) (m+nrl-NR_END));
  569. }
  570.  
  571. void free_dmatrix(m,nrl,nrh,ncl,nch)
  572. double **m;
  573. long nch,ncl,nrh,nrl;
  574. /* free a double matrix allocated by dmatrix() */
  575. {
  576.     free((FREE_ARG) (m[nrl]+ncl-NR_END));
  577.     free((FREE_ARG) (m+nrl-NR_END));
  578. }
  579.  
  580. void free_imatrix(m,nrl,nrh,ncl,nch)
  581. int **m;
  582. long nch,ncl,nrh,nrl;
  583. /* free an int matrix allocated by imatrix() */
  584. {
  585.     free((FREE_ARG) (m[nrl]+ncl-NR_END));
  586.     free((FREE_ARG) (m+nrl-NR_END));
  587. }
  588.  
  589. void free_submatrix(b,nrl,nrh,ncl,nch)
  590. float **b;
  591. long nch,ncl,nrh,nrl;
  592. /* free a submatrix allocated by submatrix() */
  593. {
  594.     free((FREE_ARG) (b+nrl-NR_END));
  595. }
  596.  
  597. void free_convert_matrix(b,nrl,nrh,ncl,nch)
  598. float **b;
  599. long nch,ncl,nrh,nrl;
  600. /* free a matrix allocated by convert_matrix() */
  601. {
  602.     free((FREE_ARG) (b+nrl-NR_END));
  603. }
  604.  
  605. void free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)
  606. float ***t;
  607. long nch,ncl,ndh,ndl,nrh,nrl;
  608. /* free a float f3tensor allocated by f3tensor() */
  609. {
  610.     free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
  611.     free((FREE_ARG) (t[nrl]+ncl-NR_END));
  612.     free((FREE_ARG) (t+nrl-NR_END));
  613. }
  614.  
  615. #endif /* ANSI */
  616.